package com.vaadin.tutorial.crm.backend.repository;

import com.vaadin.tutorial.crm.backend.entity.Score;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ScoreRepository extends JpaRepository<Score, Long> {
    @Query("select sc from Score sc " +
            "where sc.student.stuNum like concat('%', :searchTerm, '%') " +
            "or sc.student.stuName like concat('%', :searchTerm, '%')")
    List<Score> search(@Param("searchTerm") String searchTerm);

    @Query("select sc from Score sc where sc.student.stuId = ?1")
    Score getScore(@Param("stuId") Integer stuId);
}
